package org.ihelpuoo.orm.handler;

import org.ihelpuoo.util.Pager;

public class LoopScope
{
	public int	start;	// inclusive
	public int	max;	// exlusive

	public static LoopScope evaluate(Pager pager, int len)
	{
		LoopScope ls = new LoopScope();
		if (null == pager)
		{
			ls.start = 0;
			ls.max = len;
		}
		else
		{
			pager.setRecordCount(len);
			ls.start = pager.firstItemAbsolutIndex() - 1;
			ls.max = ls.start + pager.getPageSize();
		}
		return ls;
	}

	@Override
	public String toString()
	{
		return "[" + start + "," + max + "]";
	}
}
